package com.hfzy.ihk.facade.freeswitchCall.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by YANFA on 2018/10/15.
 */
public enum MsgTypeEnum {


    NORMAL("普通文本消息","normal"),
    MUTE("静音消息","mute"),
    END("结束消息","end");


    /** 描述 */
    private String desc;
    /** 枚举值 */
    private String value;

    private MsgTypeEnum(String desc, String value) {
        this.desc = desc;
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static Map<String, MsgTypeEnum> descMap = new HashMap<String, MsgTypeEnum>();

    private static Map<String, MsgTypeEnum> map = new HashMap<String, MsgTypeEnum>();

    private static Map<String, String> keyMap = new HashMap<String, String>();

    static {
        for (MsgTypeEnum value : MsgTypeEnum.values())
            keyMap.put(value.getValue() + "", value.getDesc());
    }

    static {
        for (MsgTypeEnum value : MsgTypeEnum.values())
            descMap.put(value.getDesc(), value);
    }

    static {
        for (MsgTypeEnum value : MsgTypeEnum.values()) {
            map.put(value.getValue() + "", value);
        }
    }





    public static MsgTypeEnum fromStr(String name) {
        MsgTypeEnum ret = map.get(name);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const "
                    + MsgTypeEnum.class + "." + name);
    }

    public static MsgTypeEnum fromDesc(String desc) {
        MsgTypeEnum ret = descMap.get(desc);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const " + MsgTypeEnum.class
                    + "." + desc);
    }

    public static String fromKey(String key) {
        String ret = keyMap.get(key);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const " + MsgTypeEnum.class
                    + "." + key);
    }
}
